<template>
  <div>
    <UserSelect
      @showModel="showModel"
      :selections="selections"
      @refreshList="parent"
      @selectAllList="selectAllList"
      @sendSelectData='selectData'
      ref="selectReflesh"
    />
    <UserInsert v-if="flag" @hideModel="hideModel"  @refreshList="parent" />
    <UserTable
      ref="reflush"
      @edit="edit"
      :allList="allList"
      @handleSelections="getSelections"
      @page="getPage"
      @openDialog="openDialog"
      :getSelectData='queryUserCondition'
    />
    <UserUpdate v-if="updateFlag" @hideModel="hideModel" :msg='tableData'  @refreshList="parent" />
    <SetRole v-if="setRole" :userInfo="user" @hideModel="hideModel"/>
  </div>
</template>
<script>
import UserSelect from "./user/UserSelect";
import UserInsert from "./user/UserInsert";
import UserTable from "./user/UserTable";
import UserUpdate from './user/UserUpdate';
import SetRole from './user/SetRole'
export default {
  components: {
    UserInsert,
    UserSelect,
    UserTable,
    UserUpdate,
    SetRole
  },

  data() {
    return {
      updateFlag:false,
      tableData: {},
      flag: false,
      selections: [],
      allList: {},
      page: {},
      setRole:false,
      user:{},
      queryUserCondition:{}
    };
  },
  methods: {
    showModel(val) {
      this.flag = val;
    },
    hideModel(val) {
      this.flag = val;
      this.updateFlag=val;
      this.setRole=val;
    },
    parent() {
      this.$refs.reflush.userList();
    },
    getSelections(val) {
      //   console.log(val);
      this.selections = val;
    },
    getPage(val) {
      // console.log(val)
      this.page.current = val.current;
      this.page.size = val.size;
    },
    selectAllList(val) {
      this.allList = val;
    },
    edit(val, flag) {
      this.updateFlag = flag;
      this.tableData = val;
    //   console.log(this.tableData);
    },
    openDialog(val,flag){
      this.setRole=flag
      this.user=val
    },
    selectData(val){
      this.queryUserCondition=val
    }
  }
};
</script>
<style lang='less' scoped>
.el-container {
  height: 490px;
  display: flex;
  flex-direction: column;
  width: 1166px;
}
</style>